<script>




    function category_del(reply_id, id_num) {


        id_num = id_num.toString();


        var AjaxUrl = "/user/p/delete_user/" + reply_id;


        $.getJSON(AjaxUrl, function (Json) {

            $("#del_category_" + id_num).html('');


        });

    }
    function update_category(update_id, id_num) {
        id_num = id_num.toString();

        var role = $("#role" + id_num).val();


        $.post("/user/p/changerole/" + update_id, {role: role}, function (result) {
            alert("更新成功");
            $("#del_category").html('');

        });


    }

</script>
<div class="main">
    <div class="title">
        <span>用户列表</span>
    </div>

    {% set ii = 0 %}
    <div class="content">


        {% for x in view %}

        <div id="del_category_{{ ii }}">

            <form class="pure-form pure-form-aligned">
                用户名：{{x.user_name}}&nbsp;&nbsp;&nbsp;&nbsp;
                当前权限：<input value="{{ x.role }}" type="text" id="role{{ ii }}" name="role">


                <a class="pure-button pure-button-primary" onclick="update_category('{{x.user_name}}', {{ ii }} );"
                   style="margin-left: 100px">修改权限</a>
                <a class="pure-button pure-button-primary" onclick="category_del('{{ x.uid }}', {{ ii }} );">删除</a>
            </form>
            <p style="border-bottom: 1px dashed #dddddd; margin-bottom: 20px">&nbsp;</p>
        </div>


        {% set ii = ii + 1 %}
        {% end %}


    </div>
</div>

